package cn.demo.service1.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class HelloService {
	@Autowired
	RestTemplate restTemplate;

	@HystrixCommand(fallbackMethod = "hiError")
	public String say(String str) throws Exception {
		// throw new Exception("@HystrixCommand");DiscoveryClient_
		return restTemplate.getForObject("http://SERVICE0/say?str="+str,
				String.class);
	}

	public String hiError(String str) {
		return "sorry,服务调用异常,进入断路器!";
	}

}
